let checks = document.querySelectorAll('.check');//拿到所有要跳转的商品
let h = document.querySelectorAll('.check h4')
let p = document.querySelectorAll('.check p')
let spans = document.querySelectorAll('.check span')
let imgs = document.querySelectorAll('.check img')

//给每个商品绑定点击跳转事件
for(let i = 0;i<checks.length;i++){
        imgs[i].src=JSON.parse(localStorage.getItem('pros'))[i]['urlImg'];
    $(h[i]).text(JSON.parse(localStorage.getItem('pros'))[i]['goods']);
    $(p[i]).text(JSON.parse(localStorage.getItem('pros'))[i]['introduce']);
    $(spans[i]).text(JSON.parse(localStorage.getItem('pros'))[i]['price']);
   }
   //点击对应商品跳转
   $('.check').click(function(){
    location.href=`./detail.html?id=${$(this).prop('id')}`//通过地址传递id
    //console.log($(this).prop('id'))
})